﻿<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php include("includes/header.php"); ?>

<?php //procesinam post
	if (isset($_POST['submit'])) {
		//$message = print_r($_POST);
		if (($_POST['pareigos']) != NULL){
			$pareigos = ($_POST['pareigos']);						
			$sql = "INSERT INTO `pareigos` (`pareigos`) ";
			$sql .= "VALUES (";
			$sql .= "'". $pareigos . "' ";
			$sql .= " );";
			//echo "SQL naujam: ".$sql; //viskas OK
			
			$result = mysql_query($sql, $connection);
				if ($result) {
					// Success!
					$temp = mysql_insert_id();
					$to = $_SERVER['HTTP_REFERER'];
					redirect_to($to);
					
				} else {
					// Display error message.
					$message .= "<p>Subject creation failed.</p>";
					$message .= "<p>" . mysql_error() . "</p>";
				};
								
								
							
			
		};	
			
		
	};



?>

			
					<article>
						<h2>Gyvenamoji vieta</h2>
	<?php echo $message."</br>";?>
	<form action="add_pareigos.php" method="post" name="add"><table width="330" border="0" cellspacing="2" cellpadding="3">
  
  <tr>
    <td>Pareigos:</td>
    <td><input name="pareigos" type="text" /></td>
  </tr>
  
  
  <tr>
    <td align="right"><input type="submit" name="submit" value="Submit"></td>
    <td><a href="<?php echo $_SERVER['HTTP_REFERER'];?>">Sugryžti</a></td>
  </tr>
</table></form>


			</article>
            
<?php require("includes/footer.php"); ?>
